<?php
error_reporting(0);
include("../connection/connection.php");
include("reportFunctions.php");
$distId=$_REQUEST['distId'];
$sqlReport = "SELECT distinct `district_id`,`district_name`,`block_id`,`block_name` FROM `tbl_lookup_location` where `district_id` = ".$distId." group by `block_id`";
$queryReport = mysql_query($sqlReport);
?>
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Block</title>
</head>
<body>
<table border="0" width="900" cellspacing="0" cellpadding="0">
	<tr>
		<td bgcolor="#E9E9E9" height="26">
		<p align="center"><span style="font-size: 9pt; font-weight: 700">
		<font face="Verdana" color="#224568">General information on Handpumps in District</font></span>
        
        </td>
	</tr>
	<tr>
		<td bgcolor="#E9E9E9" height="56">
		<table border="1" width="900" cellspacing="0" cellpadding="0" height="47" bgcolor="#C5D8EB">
			<tr>
				<!--<td width="80" align="center">
				<font style="font-size: 8.5pt" face="Verdana">District</font></td>-->
				<td width="80" align="center">
				<font style="font-size: 8.5pt" face="Verdana"><b>Block</b></font></td>
				<td width="41" align="center">
				<p align="center"><font face="Verdana" style="font-size: 8.5pt">
				<b>Schemes</b></font></td>
				<td width="60" align="center">
				<font style="font-size: 8.5pt" face="Verdana"><b>No. of Main Habitation (No.)</b></font></td>
				<td width="70" align="center">
				<font style="font-size: 8.5pt" face="Verdana"><b>No. of Other Habitation (No.)</b></font></td>
				<td width="60" align="center">
				<font face="Verdana" style="font-size: 8.5pt"><b>No. of HP in Main Habitation (No.)</b></font></td>
				<td width="60" align="center">
				<font face="Verdana" style="font-size: 8.5pt"><b>No. of HP in Other Habitation (No.)</b></font></td>
				<td width="60" align="center">
				<font face="Verdana" style="font-size: 8.5pt"><b>Total No. of HP (No.)</b></font></td>
				<td width="60" align="center">
				<font face="Verdana" style="font-size: 8.5pt"><b>Population 2001</b></font></td>
                <td width="60" align="center">
				<font face="Verdana" style="font-size: 8.5pt"><b>Population 2010</b></font></td>
                <td width="60" align="center">
				<font face="Verdana" style="font-size: 8.5pt"><b>Population as per design</b></font></td>
                <td width="60" align="center">
				<font face="Verdana" style="font-size: 8.5pt"><b>Water demand as per 2010 population (KLD)</b></font></td>
                <td width="60" align="center">
				<font face="Verdana" style="font-size: 8.5pt"><b>Water demand as per design (KLD)</b></font></td>
            </tr>
			<?php
			//$numVillage=0;
			//$numFormVill=0;
			while($rowReport = mysql_fetch_array($queryReport)) {
			If($rowReport['district_id']==389 or $rowReport['district_id']==390 or $rowReport['district_id']==391 or $rowReport['district_id']==398 or $rowReport['district_id']==392 or $rowReport['district_id']==401 or $rowReport['district_id']==402 or $rowReport['district_id']==403 or $rowReport['district_id']==404 or $rowReport['district_id']==405 or $rowReport['district_id']==406 or $rowReport['district_id']==416)
			{
			$lpcd=70;
			}else{
			$lpcd=40;
			}
            $a=getSchemeNoBlockWise($distId,'HP',$rowReport['block_id']);
            $b=getTotalHabitationWise('type_mh_oh','MH',$rowReport['block_id']);
            $c=getTotalHabitationWise('type_mh_oh','OH',$rowReport['block_id']);
            $d=getDPpopulation('population_benefited',$rowReport['block_id']);
            $e=getSumHabitationWise('hp_no','MH',$rowReport['block_id']);
            $f=getSumHabitationWise('hp_no','OH',$rowReport['block_id']);
            $g=getDPpopulation('present_population',$rowReport['block_id']);
            $h=getDPpopulation('DP_population',$rowReport['block_id']);
            $i=$h*$lpcd/1000;//number_format(getDPpopulation('DP_water_demand',$rowReport['block_id']),2,'.','');
			$WaterFactor=$g*$lpcd/1000;
            $sum1=$e+$f;
            $getSumHabitation1+=$f;
            $getSchemeNoBlockWise+=$a;
            $getTotalHabitationWise+=$b;
            $totalHabitation+=$c;
            $totaldppop+=$d;
            $SumHabitation+=$e;
            $SumDPpopulation+=$g;
            $SumDPpopulation1+=$h;
            $SumDPpopulation2+=$i;
            $grandsum+=$sum1;
			$TotalWaterFactor+=$WaterFactor;
			?><tr bgcolor="#FFFFFF">
				
				<!--<td width="80" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php //echo $rowReport['district_name'];?></font></td>-->
				<td align="center" width="80"><font style="font-size: 8.5pt" face="Verdana"><?php echo $rowReport['block_name'];?></font></td>
				<td align="center" width="41"><font style="font-size: 8.5pt" face="Verdana"><?php echo getSchemeNoBlockWise($distId,'HP',$rowReport['block_id']);?></font></td>
				<td align="center" width="60"><font style="font-size: 8.5pt" face="Verdana"><?php echo getTotalHabitationWise('type_mh_oh','MH',$rowReport['block_id']);?></font></td>
				<td align="center" width="70"><font style="font-size: 8.5pt" face="Verdana"><?php echo getTotalHabitationWise('type_mh_oh','OH',$rowReport['block_id']);?></font></td>
				<td width="60" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php 
				$SumHabitWise=getSumHabitationWise('hp_no','MH',$rowReport['block_id']);
				if($SumHabitWise=='')
				{
					echo $SumHabitWise=0;
				}
				else
				{
					echo $SumHabitWise;
				}
				
				?></font></td>
				<td align="center" width="60"><font style="font-size: 8.5pt" face="Verdana"><?php 
				$SumHabOH=getSumHabitationWise('hp_no','OH',$rowReport['block_id']);
				if($SumHabOH=='')
				{
					echo $SumHabOH=0;
				}
				else
				{
					echo $SumHabOH;
				}
				?></font></td>
				<td align="center" width="60"><font style="font-size: 8.5pt" face="Verdana"><?php echo $sum1;?></font></td>
				<td align="center" width="60"><font style="font-size: 8.5pt" face="Verdana"><?php 
				$dppopulation=getDPpopulation('population_benefited',$rowReport['block_id']);
				if($dppopulation=='')
				{
					echo $dppopulation=0;
				}
				else
				{
					echo $dppopulation;
				}
				
				?></font></td>
                <td align="center" width="60"><font style="font-size: 8.5pt" face="Verdana"><?php 
				$dppop2010=getDPpopulation('present_population',$rowReport['block_id']);
				if($dppop2010=='')
				{
					echo $dppop2010=0;
				}
				else
				{
					echo $dppop2010;
				}
				?></font></td>
                <td align="center" width="60"><font style="font-size: 8.5pt" face="Verdana">
                  <?php 
				//$DPpopulation=number_format(getDPpopulation('DP_population',$rowReport['block_id']),2,'.','');
				if($h==0 || $h=='')
				{
					echo $h='NP';
				}
				else
				{
					echo round($h);
				}
				
				?>
                </font></td>
                <td align="center" width="60"><font style="font-size: 8.5pt" face="Verdana"><?php  echo number_format($WaterFactor,2,'.','');?></font></td>
                <td align="center" width="60"><font style="font-size: 8.5pt" face="Verdana"><?php 
				//$dppopwd=getDPpopulation('DP_water_demand',$rowReport['block_id']);
				if($i==0)
				{
					echo $i=0;
				}
				else
				{
					echo number_format($i,2,'.','');
				}
				?></font></td>
                </tr>
			<?php
			
			}
			?>
			<tr bgcolor="#E9E9E9">
				<td colspan="1" align="center"><font style="font-size: 8.5pt" face="Verdana"><b>Total</b></font></td>
				<td align="center" width="41"><font style="font-size: 8.5pt" face="Verdana"><b><?php echo $getSchemeNoBlockWise;?></b></font></td>
				<td align="center" width="60"><font style="font-size: 8.5pt" face="Verdana"><b><?php echo $getTotalHabitationWise;?></b></font></td>
				<td align="center" width="70"><font style="font-size: 8.5pt" face="Verdana"><b><?php echo $totalHabitation;?></b></font></td>
				<td width="60" align="center"><font style="font-size: 8.5pt" face="Verdana"><b><?php echo $SumHabitation;?></b></font></td>
				<td align="center" width="60"><font style="font-size: 8.5pt" face="Verdana"><b><?php echo $getSumHabitation1;?></b></font></td>
				<td align="center" width="60"><font style="font-size: 8.5pt" face="Verdana"><b><?php echo $grandsum;?></b></font></td>
				<td align="center" width="60"><font style="font-size: 8.5pt" face="Verdana"><b><?php echo $totaldppop;?></b></font></td>
                <td align="center" width="60"><font style="font-size: 8.5pt" face="Verdana"><b><?php echo $SumDPpopulation;?></b></font></td>
                <td align="center" width="60"><font style="font-size: 8.5pt" face="Verdana"><b><?php echo round($SumDPpopulation1);?></b></font></td>
                <td align="center" width="60"><font style="font-size: 8.5pt" face="Verdana"><b><?php echo number_format($TotalWaterFactor,2,'.','');?></b></font></td>
                <td align="center" width="60"><font style="font-size: 8.5pt" face="Verdana"><b><?php echo number_format($SumDPpopulation2,2,'.','');?></b></font></td>
            </tr>
		</table>
		</td>
	</tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>


</body>

</html>